package br.org.acessobrasil.portal.util;

import org.springframework.jdbc.datasource.DriverManagerDataSource;
/**
 * Adapta&ccedil;&atilde;o para path relativo a aplica&ccedil;&atilde;o caso seja hsqldb
 * @author Fabio Issamu Oshiro
 *
 */
public class DataSourceRelativo extends DriverManagerDataSource {
	@Override
	public void setUrl(String url) {
		if (url.startsWith("jdbc:hsqldb:file:")) {
			String path = this.getClass().getClassLoader().getResource("MessageResources.properties").getPath();
			path = path.replace("classes/MessageResources.properties", "db/cms");
			super.setUrl("jdbc:hsqldb:file:" + path.substring(1));
		} else {
			super.setUrl(url);
		}
	}
}
